<h1>Import mappings</h1>
<p>This page allows the user to upload a CSV (comma separated value) file specifying pre-existing mappings for a fragment.</p>

<div class="emphasize">
  <p><em>You must adhere to these CSV formatting rules when importing mappings.</em></p>
  <ol>
    <li>NO column headers (column names).  The first row in your .csv file should be a data row.</li>
    <li>The first column is the site fragment local key for the concept that you are mapping FROM.</li>
    <li>The second column is the site fragment local key for the concept that you are mapping TO.</li>
    <li>The third column is optional (unless you want to include comments in your import, in which case you MUST include column 3, however, it can be left blank and all mappings will default to "synonyms") and indicates the ID of the mapping type for that row.  You can see the ID's for mapping types <%= link_to "here", mapping_types_path %>.</li>
    <li>The fourth column is also optional.  Enter comment data in the fourth column if you wish to import comments for any mappings.</li>
  </ol>
</div>

<% form_tag url_for(:action => "upload_mappings", :id => @fragment.id), :multipart => true do %>
  <div class="form_field_box">
    <span class="form_field_label">From Fragment: </span>
    <span><%= @fragment.name %></span>
  </div>
  <div class="form_field_box">
    <span class="form_field_label">To Fragment: </span>
    <span><%= select_tag "map_to_fragment_id", "<option></option>" << options_from_collection_for_select(@core_fragments, :id, :name) %></span>
  </div>

  <div class="form_field_box">
    <span class="form_field_label">Mappings file: </span>
    <span><%= file_field_tag 'file' %></span>
  </div>

  <div class="form_field_box">
    <%= submit_tag "Import" %>
  </div>
<% end %>

<%= link_to 'Back', fragments_path %>
